package com.qq.weixin.mp.api.pay.model;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import com.hxexp.weixin.common.jaxb.CDATAAdapter;

/**
 * 统一下单接口返回结果
 * 参考文档：http://mch.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1
 * @author li.jiang
 *
 */
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public final class UnifiedOrderJaxb extends PayCommonJaxb {

    private static final long serialVersionUID = -5485095720106785819L;
    /**
     * 设备号【调用接口提交的终端设备号】
     */
    @XmlElement(name = "device_info")
    @XmlJavaTypeAdapter(value = CDATAAdapter.class)
    private String deviceInfo;
    /**
     * 交易类型(微信服务号内部网页支付使用JSAPI)
     */
    @XmlElement(name = "trade_type")
    @XmlJavaTypeAdapter(value = CDATAAdapter.class)
    private String tradeType;
    /**
     * 预支付交易会话标识 (用于后续接口调用中使用，该值有效期为2小时 )
     */
    @XmlElement(name = "prepay_id")
    @XmlJavaTypeAdapter(value = CDATAAdapter.class)
    private String prepayId;
    /**
     * 二维码链接 (trade_type为NATIVE是有返回，可将该参数值生成二维码展示出来进行扫码支付 )
     */
    @XmlElement(name = "code_url")
    @XmlJavaTypeAdapter(value = CDATAAdapter.class)
    private String codeUrl;
    /**
     * @return the deviceInfo
     */
    public String getDeviceInfo() {
        return deviceInfo;
    }
    /**
     * @param deviceInfo the deviceInfo to set
     */
    public void setDeviceInfo(String deviceInfo) {
        this.deviceInfo = deviceInfo;
    }
    /**
     * @return the tradeType
     */
    public String getTradeType() {
        return tradeType;
    }
    /**
     * @param tradeType the tradeType to set
     */
    public void setTradeType(String tradeType) {
        this.tradeType = tradeType;
    }
    /**
     * @return the prepay_id
     */
    public String getPrepayId() {
        return prepayId;
    }
    /**
     * @param prepayId the prepay_id to set
     */
    public void setPrepayId(String prepayId) {
        this.prepayId = prepayId;
    }
    /**
     * @return the code_url
     */
    public String getCodeUrl() {
        return codeUrl;
    }
    /**
     * @param codeUrl the code_url to set
     */
    public void setCodeUrl(String codeUrl) {
        this.codeUrl = codeUrl;
    }
    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return String
                .format("UnifiedOrderJaxb [deviceInfo=%s, tradeType=%s, prepay_id=%s, code_url=%s, returnCode=%s, returnMsg=%s, appId=%s, mchId=%s, nonceStr=%s, sign=%s, resultCode=%s, errCode=%s, errCodeDes=%s]",
                        deviceInfo, tradeType, prepayId, codeUrl, getReturnCode(), getReturnMsg(), getAppId(),
                        getMchId(), getNonceStr(), getSign(), getResultCode(), getErrCode(), getErrCodeDes());
    }

}
